<include file="Inc/html_header" />
<div class="searchBox mySelect">
    <a href="<?php echo U('node/node_add'); ?>" class="btn btn-primary">添加一级节点</a>
</div>
<div class="mtop10">
    <table class="table table-bordered table-hover">
        <thead>
            <tr>
                <th width="40">ID</th>
                <th>节点名称</th>
                <th>节点地址</th>
                <th width="100">显示级别</th>
                <th width="60">状态</th>
                <th width="60">排序</th>
                <th width="250">操作</th>
            </tr>
        </thead>
        <tbody>
        <?php
        if( ! empty($list)){
            foreach($list as $v){
                $v['node_level'] = intval($v['node_level']);
                $v['st'] = intval($v['st']);
                $v['node_pid'] = intval($v['node_pid']);
        ?>
        <tr <?php if($v['node_pid'] == 0){ echo 'class="success"'; }?> >
            <td class="tdf"><?php echo $v['node_id'];;?></td>
            <td><strong><?php echo $v['node_name'];?></strong></td>
            <td><strong><?php echo $v['m_c_a'];?></strong></td>
            <td <?php if($v['node_level']===1 || $v['node_level']===2){echo 'class="danger"';}?> ><?php echo $menuLevel[$v['node_level']]; ?></td>
            <td align="center"><span class="c_p" onclick="nodeStatus(<?php echo $v['node_id'];?>, <?php echo (1-$v['st']);?>)"><?php if($v['st']===1){echo '<span class="color_1">正常</span>';}else{echo '<span class="color_0">禁用</span>';}?></span></td>
            <td><?php echo $v['px'];?></td>
            <td>
                <a href="<?php echo U('node/node_add', array('node_pid'=>$v['node_id']));?>">添加子菜单</a> /
                <?php if($v['node_pid'] === 0){?><a href="<?php echo U('node/node_list', array('node_pid'=>$v['node_id']));?>">管理子菜单</a> / <?php }?>
                <a href="<?php echo U('node/node_del', array('node_id'=>$v['node_id']));?>" onclick="javascript:return confirm('提示：您确定要删除吗？')">删除</a> /
                <a href="<?php echo U('node/node_edit', array('node_id'=>$v['node_id']));?>">修改</a>
            </td>
        </tr>
        <!--Begin::左边二三级菜单、隐藏菜单-->
        <?php
                if(is_array($v['_sub'])){
                    foreach($v['_sub'] as $vv){
                        $vv['node_level'] = intval($vv['node_level']);
                        $vv['st'] = intval($vv['st']);
        ?>
        <tr>
            <td class="tdf"><?php echo $vv['node_id'];;?></td>
            <td style="padding-left:30px;"><?php echo $vv['node_name'];?></td>
            <td style="padding-left:30px;"><?php echo $vv['m_c_a'];?></td>
            <td <?php if($vv['node_level']===1){echo 'class="danger"';}?> ><?php echo $menuLevel[$vv['node_level']]; ?></td>
            <td align="center"><span class="c_p" onclick="nodeStatus(<?php echo $vv['node_id'];?>, <?php echo (1-$vv['st']);?>)"><?php if($vv['st']==1){echo '<span class="color_1">正常</span>';}else{echo '<span class="color_0">禁用</span>';}?></span></td>
            <td style="padding-left:30px;"><?php echo $vv['px'];?></td>
            <td>
                <a href="<?php echo U('node/node_del', array('node_id'=>$vv['node_id']));?>" onclick="javascript:return confirm('提示：您确定要删除吗？')">删除</a> /
                <a href="<?php echo U('node/node_edit', array('node_id'=>$vv['node_id']));?>">修改</a>
            </td>
        </tr>
        <?php }}?>
        <!--End::左边二三级菜单、隐藏菜单-->
        <?php }}else{?>
        <tr>
            <td colspan="7">没有数据</td>
        </tr>
        <?php }?>
        </tbody>
    </table>
</div>
<script type="text/javascript">
    function nodeStatus(node_id, st)
    {
        if( ! confirm('确认？')){ return false; }
        $.ajax({
            url:'<?php echo U('node/ajax_node_st');?>',
            data:({'node_id':node_id, 'st':st}),
            type:'post',
            dataType:'json',
            success:function(msg){
                if(msg.st == 'y'){
                    window.location.reload();
                }else{
                    alert(msg.note);
                }
            },
            error:function(){
                alert('网络繁忙，请稍后重试');
            }
        })
    }
</script>
<include file="Inc/html_footer" />